package com.photoeditor.demo.statistics;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.TextUtils;

import com.android.billingclient.api.Purchase;
import com.appsflyer.AppsFlyerLib;
import com.common.base.ComponentContext;
import com.common.base.log.RLog;
import com.common.base.service.ScheduleJobService;
import com.common.base.utils.AppUtils;
import com.common.base.utils.DebugUtil;
import com.common.base.utils.SystemUtils;
import com.common.commercialize.utils.SubEventUtil;
import com.photoeditor.demo.app.TestUser;
import com.photoeditor.demo.util.TimeConstant;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

//import com.photoeditor.demo.ui.main.CameraFragment;

/**
 * Created by mutour on 2017/1/18.
 */

public class StatisticsUtils {


    public static void statisticGrowingIo(String event, String... values) {
        com.common.statistics.StatisticsUtils.statisicsGrowing(event, values);
    }

    public static void updateUserProperty(String property, String value) {
        com.common.statistics.StatisticsUtils.updateUserProperty(property, value);
    }


    public static void statisicsMessageCustom(final String msgID,
                                              final String msgType) {
        List<String> path = new ArrayList<String>() {
            {add(StatisticsConstant.UMENG_EVNET_message_custom);}
            {add(msgID);}
            {add(SystemUtils.getCountry(ComponentContext.getContext()));}
            {add(String.valueOf(AppUtils.getVersionCode(ComponentContext.getContext())));}
            {add(StatisticsConstant.UMENG_message_custom_type_obtain);}
        };
//        UmengStatistics.Event.onEvent(ComponentContext.getContext(), path, 1, msgType);
    }


    private static String parseValues(String... value) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < value.length; i++) {
            if (i != 0) {
                sb.append("_");
            }
            sb.append(value[i]);
        }
        return sb.toString();
    }

    public static void statisicsCustom(String prefix, String event, @Nullable String key, @Nullable String value) {
//        String buyuser = BuyUserManager.getInstance().getBuyUserSource();
//        if (TextUtils.isEmpty(key) || TextUtils.isEmpty(value)) {
//            com.common.statistics.StatisticsUtils.statisics(prefix, event,
//                    StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_BUYUSERSOURCE, buyuser,
//                    "usertype", String.valueOf(CommercializeSDK.getInstance().isBuyUser()));
//        } else {
//            com.common.statistics.StatisticsUtils.statisics(prefix, event,
//                    key, value,
//                    StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_BUYUSERSOURCE, buyuser,
//                    "usertype", String.valueOf(CommercializeSDK.getInstance().isBuyUser()));
//        }
    }

    public static void statisicsCustom(String prefix, String event, @Nullable String state) {
//        statisicsCustom(prefix, event, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_STATE, state);
    }


    public static void statisicsCustomFunction(String event, @Nullable String state) {
//        statisicsCustom(StatisticsConstant.UMENG_CUSTOM_EVENT_PREFIX_FUNCTION, event,
//                state);
    }

    public static void statisicsCustomFunction(String event) {
//        com.common.statistics.StatisticsUtils.statisics(StatisticsConstant.UMENG_CUSTOM_EVENT_PREFIX_FUNCTION, event);
    }

    public static void statisicsCustomFunction(String event, String key, String value) {
//        statisicsCustom(StatisticsConstant.UMENG_CUSTOM_EVENT_PREFIX_FUNCTION, event,
//                key, statisticsComment() + StatisticsConstant.UMENG_CUSTOM_UNDER_LINE + value);
    }


    // 主界面事件——点击
    public static void statisticsCustomCampageClick(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_CAMPAGE, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_CLICK, who);
    }
    // 主界面事件——show
    public static void statisticsCustomCampageShow(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_CAMPAGE, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_SHOW, who);
    }

    // Photo editor 主界面事件——点击
    public static void statisticsCustomMainpageClick(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_EDITOR, StatisticsConstant.UMENG_CUSTOM_KEY_FUNCTION,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_MAINPAGE + StatisticsConstant.UMENG_CUSTOM_UNDER_LINE + who);
    }

    // Photo editor 主界面事件——展示
    public static void statisticsCustomMainpageShow(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_EDITOR, StatisticsConstant.UMENG_CUSTOM_KEY_FUNCTION,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_MAINPAGE + StatisticsConstant.UMENG_CUSTOM_UNDER_LINE + who);
    }

    // 图片预览（编辑）事件——点击
    public static void statisticsCustomPreviewClick(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_PREVIEW, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_CLICK, who);
    }

    public static void statisticsCustomPreviewShow(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_PREVIEW, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_SHOW, who);
    }

    // 滤镜商店事件——点击
    public static void statisticsCustomStoreClick(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_STORE, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_CLICK, who);
    }
    // 滤镜商店事件——展示
    public static void statisticsCustomStoreShow(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_STORE, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_SHOW, who);
    }

    // 暂存页面点击统计
    public static void statisticsStashClick(String who) {
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_STASH, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_CLICK, who);
    }
    // 暂存页面状态统计
    public static void statisticsStashStatus(String who) {
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_STASH, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_STATUS, who);

    }
    // 视频暂存页面点击统计
    public static void statisticsVideoStashClick(String who) {
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_VIDEO_STASH, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_CLICK, who);
    }
    // 设置页面点击统计
    public static void statisticsSettingClick(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_SETTING, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_CLICK, who);
    }


    // 主界面beauty按钮事件——点击
    public static void statisticsCustomBeautyBtnClick(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_MAINPAGE_BTN_BEAUTY, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_CLICK, who);
    }

    // 主界面collage按钮事件——点击
    public static void statisticsCustomCollageBtnClick(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_MAINPAGE_BTN_COLLAGE, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_CLICK, who);
    }

    public static void statisticsCustomFreestyleBtnClick(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_MAINPAGE_BTN_FREESTYLE, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_CLICK, who);
    }

    // 主界面eidt按钮事件——点击
    public static void statisticsCustomEditBtnClick(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_MAINPAGE_BTN_EDIT, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_CLICK, who);
    }

    // 主界面selfie按钮事件——点击
    public static void statisticsCustomSelfieBtnClick(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_MAINPAGE_BTN_SELFIE, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_CLICK, who);
    }

    // 主界面gallery按钮事件——点击
    public static void statisticsCustomGalleryBtnClick(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_MAINPAGE_BTN_GALLERY, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_CLICK, who);
    }

    // 主界面effect按钮事件——点击
    public static void statisticsCustomEffectBtnClick(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_MAINPAGE_BTN_EFFECT, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_CLICK, who);
    }

    // 资源应用次数 包名区分 all
    public static void statisticsCustomStoreAllApply(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_STORE_ALL_APPLY, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_CLICK, who);
    }

    public static void statisticsCustomStoreAllDownload(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_STORE_ALL_DOWNLOAD, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_CLICK, who);
    }

    public static void statisticsCustomStoreAllShow(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_STORE_ALL_SHOW, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_SHOW, who);
    }

    public static void statisticsCustomStoreAllClick(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_STORE_ALL_CLICK, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_CLICK, who);
    }

    // 资源应用次数 包名区分 主界面
    public static void statisticsCustomStoreMainApply(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_STORE_MAIN_APPLY, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_CLICK, who);
    }

    public static void statisticsCustomStoreMainDownload(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_STORE_MAIN_DOWNLOAD, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_CLICK, who);
    }

    public static void statisticsCustomStoreMainShow(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_STORE_MAIN_SHOW, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_SHOW, who);
    }

    public static void statisticsCustomStoreMainClick(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_STORE_MAIN_CLICK, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_CLICK, who);
    }

    // 资源应用次数 包名区分 贴纸商店
    public static void statisticsCustomStoreStickerApply(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_STORE_STICKER_APPLY, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_CLICK, who);
    }

    public static void statisticsCustomStoreStickerDownload(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_STORE_STICKER_DOWNLOAD, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_CLICK, who);
    }

    public static void statisticsCustomStoreStickerShow(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_STORE_STICKER_SHOW, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_SHOW, who);
    }

    public static void statisticsCustomStoreStickerClick(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_STORE_STICKER_CLICK, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_CLICK, who);
    }

    // 资源应用次数 包名区分 滤镜商店
    public static void statisticsCustomStoreFilterApply(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_STORE_FILTER_APPLY, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_CLICK, who);
    }

    public static void statisticsCustomStoreFilterDownload(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_STORE_FILTER_DOWNLOAD, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_CLICK, who);
    }

    public static void statisticsCustomStoreFilterShow(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_STORE_FILTER_SHOW, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_SHOW, who);
    }

    public static void statisticsCustomStoreFilterClick(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_STORE_FILTER_CLICK, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_CLICK, who);
    }

    // 资源应用次数 包名区分 背景商店
    public static void statisticsCustomStoreBackgroundApply(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_STORE_BACKGROUND_APPLY, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_CLICK, who);
    }

    public static void statisticsCustomStoreBackgroundDownload(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_STORE_BACKGROUND_DOWNLOAD, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_CLICK, who);
    }

    public static void statisticsCustomStoreBackgroundShow(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_STORE_BACKGROUND_SHOW, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_SHOW, who);
    }

    public static void statisticsCustomStoreBackgroundClick(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_STORE_BACKGROUND_CLICK, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_CLICK, who);
    }

    public static void statisticsCustomStoreTemplateClick(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_STORE_TEMPLATE_CLICK, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_CLICK, who);
    }
    public static void statisticsCustomStoreTemplateApply(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_STORE_TEMPLATE_APPLY, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_CLICK, who);
    }
    public static void statisticsCustomStoreTemplateDownload(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_STORE_TEMPLATE_DOWNLOAD, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_CLICK, who);
    }
    public static void statisticsCustomStoreTemplateShow(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_STORE_TEMPLATE_SHOW, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_SHOW, who);
    }



    //商店gif
    public static void statisticsCustomStoreGifApply(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_STORE_GIF_APPLY, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_CLICK, who);
    }

    public static void statisticsCustomStoreGifClick(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_STORE_GIF_CLICK, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_SHOW, who);
    }

    public static void statisticsCustomStoreGifShow(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_STORE_GIF_SHOW, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_SHOW, who);
    }

    //主页gif
    public static void statisticsCustomMainGifApply(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_MAIN_GIF_APPLY, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_CLICK, who);
    }

    public static void statisticsCustomMainGifClick(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_MAIN_GIF_CLICK, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_CLICK, who);
    }

    public static void statisticsCustomMainGifShow(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_MAIN_GIF_SHOW, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_SHOW, who);
    }

    // Freestyle——点击
    public static void statisticsCustomFreestyleClick(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_FREESTYLE, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_CLICK, who);
    }
    // Freestyle——展示
    public static void statisticsCustomFreestyleShow(String who){
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_FREESTYLE, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_SHOW, who);
    }


    public static void statisicsCustomFunction(String event, int duration) {
//        statisicsCustom(StatisticsConstant.UMENG_CUSTOM_EVENT_PREFIX_FUNCTION, event,
//                duration);
    }

    public static void statisicsCustom(String prefix, String event, int duration) {
        com.common.statistics.StatisticsUtils.statisics(prefix, event, duration);
    }

    public static void statisicsCustomLockscreen(@NonNull String type) {
//        statisicsCustom(StatisticsConstant.UMENG_CUSTOM_EVENT_PREFIX_FUNCTION,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_LOCKSCREEN,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_TYPE, type);
    }

    public static void statisicsCustomBuyUser(String source, String type) {
//        com.common.statistics.StatisticsUtils.statisics(
//                StatisticsConstant.UMENG_CUSTOM_EVENT_PREFIX_FUNCTION,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_BUYUSER,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_TYPE, type,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_BUYUSER_KEY_SOURCE, source);
    }

    public static void statisicsCustomNotificationBar(String type) {
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_NOTIFICATIONBAR,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_TYPE, type);
    }

    public static void statisicsCustomMainPage(String action) {
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_MAIN_PAGE,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_ACTION, action);
    }

    public static void statisicsCustomRateGuide(String action) {
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_EDITOR,
//                StatisticsConstant.UMENG_CUSTOM_KEY_FUNCTION, StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_RATE_GUIDE +
//                        StatisticsConstant.UMENG_CUSTOM_UNDER_LINE + action);
    }

    public static void statisicsCustomDesktopWidget(String action) {
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_WIDGET,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_ACTION, action);
    }

    public static void statisicsCustomIncallGuide(String action) {
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_INCALL_GUIDE,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_ACTION, action);
    }

    public static void statisticsShareDialogClick(String from, String who){
//        statisicsCustomFunction(from, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_CLICK, who);
    }

    public static void statisticsSaveImgError(String msg) {
//        String model = android.os.Build.BRAND + ":" + android.os.Build.MODEL + ":" + Build.VERSION.SDK_INT;
//        com.common.statistics.StatisticsUtils.statisics(StatisticsConstant.UMENG_CUSTOM_EVENT_PREFIX_FUNCTION,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_SAVE_IMG_ERROR,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_ERROR_MSG, msg,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_ERROR_PHONE, model,
//                UMENG_CUSTOM_EVENT_FUNC_STORAGE_SIZE, FileUtil.getExternalStorageInfoSize());
    }

    public static void statisticsEditResult(boolean result) {
//        com.common.statistics.StatisticsUtils.statisics(StatisticsConstant.UMENG_CUSTOM_EVENT_PREFIX_FUNCTION,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_EDIT_RESULT,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_RESULT, String.valueOf(result));
    }

    public static void statisticsGridResult(boolean result) {
//        com.common.statistics.StatisticsUtils.statisics(StatisticsConstant.UMENG_CUSTOM_EVENT_PREFIX_FUNCTION,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_GRID_RESULT,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_RESULT, String.valueOf(result));
    }

    public static void statisticsFreeStyleResult(boolean result) {
//        com.common.statistics.StatisticsUtils.statisics(StatisticsConstant.UMENG_CUSTOM_EVENT_PREFIX_FUNCTION,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_FREESTYLE_RESULT,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_RESULT, String.valueOf(result));
    }

    public static void statisticsMakeVideoResult(String from, boolean result, int videoW, int videoH) {
//        com.common.statistics.StatisticsUtils.statisics(StatisticsConstant.UMENG_CUSTOM_EVENT_PREFIX_FUNCTION,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_MAKE_VIDEO_RESULT,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_RESULT, from + "_" + String.valueOf(result));
//        String event = StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_MAKE_VIDEO_SUCCESS_SIZE;
//        if (!result) {
//            event = StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_MAKE_VIDEO_FAIL_SIZE;
//        }
//        boolean support = true;
//        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
//            support = MediaCodecHelper.getInstance().isResolutionSupported(videoW, videoH);
//        }
//        com.common.statistics.StatisticsUtils.statisics(StatisticsConstant.UMENG_CUSTOM_EVENT_PREFIX_FUNCTION,
//                event,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_RESULT, from + "_" + videoW + "x" + videoH,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_RES_SIZE, String.valueOf(support));
    }

    public static void statisticsMakeVideoError(String msg, int videoW, int videoH) {
//        String model = android.os.Build.BRAND + ":" + android.os.Build.MODEL + ":" + Build.VERSION.SDK_INT + ":" + Build.CPU_ABI;
//        com.common.statistics.StatisticsUtils.statisics(StatisticsConstant.UMENG_CUSTOM_EVENT_PREFIX_FUNCTION,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_MAKE_VIDEO_ERROR,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_ERROR_MSG, videoW + "x" + videoH + "_" + msg,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_ERROR_PHONE, model,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_RES_SIZE, videoW + "_" + videoH,
//                UMENG_CUSTOM_EVENT_FUNC_STORAGE_SIZE, FileUtil.getExternalStorageInfoSize());
    }

    public static void statisticsFfmpegError(String cmd, String msg, boolean fileExist, boolean ffmpegExec) {
//        String model = android.os.Build.BRAND + ":" + android.os.Build.MODEL + ":" + Build.VERSION.SDK_INT + ":" + Build.CPU_ABI;
//        com.common.statistics.StatisticsUtils.statisics(StatisticsConstant.UMENG_CUSTOM_EVENT_PREFIX_FUNCTION,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_MAKE_VIDEO_ERROR_FFMPEG,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_CMD, cmd,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_ERROR_MSG, msg,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_ERROR_PHONE, model,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_OUTPUT_FILE_EXIST, String.valueOf(fileExist),
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_FFMPEG_EXEC, String.valueOf(ffmpegExec),
//                UMENG_CUSTOM_EVENT_FUNC_STORAGE_SIZE, FileUtil.getExternalStorageInfoSize());
    }

    public static void statisticsFfmpegDTEntryError(String cmd, String msg, boolean fileExist, boolean ffmpegExec) {
//        String model = android.os.Build.BRAND + ":" + android.os.Build.MODEL + ":" + Build.VERSION.SDK_INT + ":" + Build.CPU_ABI;
//        com.common.statistics.StatisticsUtils.statisics(StatisticsConstant.UMENG_CUSTOM_EVENT_PREFIX_FUNCTION,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_FFMPEG_DT_ENTRY_ERROR,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_CMD, cmd,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_ERROR_MSG, msg,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_ERROR_PHONE, model,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_OUTPUT_FILE_EXIST, String.valueOf(fileExist),
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_FFMPEG_EXEC, String.valueOf(ffmpegExec),
//                UMENG_CUSTOM_EVENT_FUNC_STORAGE_SIZE, FileUtil.getExternalStorageInfoSize());
    }

    public static void statisticsFfmpegNoFileError(String cmd, String msg, boolean fileExist, boolean ffmpegExec, String noFileName) {
//        String model = android.os.Build.BRAND + ":" + android.os.Build.MODEL + ":" + Build.VERSION.SDK_INT + ":" + Build.CPU_ABI;
//        com.common.statistics.StatisticsUtils.statisics(StatisticsConstant.UMENG_CUSTOM_EVENT_PREFIX_FUNCTION,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_FFMPEG_NO_FILE_ERROR,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_CMD, cmd,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_ERROR_MSG, msg,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_ERROR_PHONE, model,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_OUTPUT_FILE_EXIST, String.valueOf(fileExist),
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_NO_FILE_NAME, noFileName,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_FFMPEG_EXEC, String.valueOf(ffmpegExec),
//                UMENG_CUSTOM_EVENT_FUNC_STORAGE_SIZE, FileUtil.getExternalStorageInfoSize());
    }

    public static void statisticsTakeImgResult(boolean result) {
//        com.common.statistics.StatisticsUtils.statisics(StatisticsConstant.UMENG_CUSTOM_EVENT_PREFIX_FUNCTION,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_TAKE_IMG_RESULT,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_RESULT, String.valueOf(result));
    }

    public static void statisticsTakeVideoResult(boolean result) {
//        com.common.statistics.StatisticsUtils.statisics(StatisticsConstant.UMENG_CUSTOM_EVENT_PREFIX_FUNCTION,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_TAKE_VIDEO_RESULT,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_RESULT, String.valueOf(result));
    }

    public static void statisticsBrokenImg() {
//        com.common.statistics.StatisticsUtils.statisics(StatisticsConstant.UMENG_CUSTOM_EVENT_PREFIX_FUNCTION,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_PREVIEW_IMG_ERROR);
    }

    /**
     * banner统计
     */

    public static void statisticsAllBannerShow() {
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_BANNER_ALL_SHOW);
    }

    public static void statisticsAllBannerClick() {
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_BANNER_ALL_CLICK);
    }

    public static void statisticsAllBannerDownload() {
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_BANNER_ALL_DOWNLOAD);
    }

    public static void statisticsAllBannerApply() {
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_BANNER_ALL_APPLY);
    }

    public static void statisticsBannerShow(String where) {
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_EDITOR, StatisticsConstant.UMENG_CUSTOM_KEY_FUNCTION,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_MAINPAGE_ + StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_BANNER +
//                        StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_SHOW + StatisticsConstant.UMENG_CUSTOM_UNDER_LINE + where);
    }

    public static void statisticsBannerClick(String where) {
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_EDITOR, StatisticsConstant.UMENG_CUSTOM_KEY_FUNCTION,
//                StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_MAINPAGE_ + StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_BANNER +
//                        StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_CLICK + StatisticsConstant.UMENG_CUSTOM_UNDER_LINE + where);
    }

    public static void statisticsBannerShow(String where, int position) {
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_BANNER_ + where + "_" + (position + 1) + StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_SHOW);
    }

    public static void statisticsBannerClick(String where, int position) {
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_BANNER_ + where + "_" + (position + 1) + StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_CLICK);
    }

    public static void statisticsBannerDownload(String where, int position) {
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_BANNER_ + where + "_" + (position + 1) + StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_DOWNLOAD);
    }

    public static void statisticsBannerApply(String where, int position) {
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_BANNER_ + where + "_" + (position + 1) + StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_APPLY);
    }

    /**
     * 主页按钮子页面统计
     */

    public static void statisticsMainBtnAlbumBack(String where) {
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_MAINPAGE_ + where + StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_ALBUM_BACK);
    }

    public static void statisticsMainBtnAlbumStart(String where) {
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_MAINPAGE_ + where + StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_ALBUM_START);
    }

    public static void statisticsMainBtnEditCancel(String where) {
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_MAINPAGE_ + where + StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_EDIT_CANCEL);
    }

    public static void statisticsMainBtnEditSave(String where, String useWhat) {
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_MAINPAGE_ + where + StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_EDIT_SAVE, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_USE, useWhat);
    }

    public static void statisticsMainBtnPreviewDelete(String where) {
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_MAINPAGE_ + where + StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_SAVE_DELETE);
    }

    public static void statisticsMainBtnPreviewEdit(String where) {
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_MAINPAGE_ + where + StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_SAVE_EDIT);
    }

    public static void statisticsMainBtnPreviewShare(String where, String useWhat) {
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_MAINPAGE_ + where + StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_SAVE_SHARE, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_USE, useWhat);
    }

    public static void statisticsNotificationContentUpdateDownload(String name) {
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_NOTIF_STORE_UPDATE_DOWNLOAD, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_USE, name);
    }

    public static void statisticsNotificationContentUpdateApply(String name) {
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_NOTIF_STORE_UPDATE_APPLY, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_USE, name);
    }

    public static void statisticsNotificationContentUpdateSave(String name) {
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_NOTIF_STORE_UPDATE_SAVE, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_USE, name);
    }

    public static void statisticsNotificationContentUpdateShare(String name, String share) {
//        statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_NOTIF_STORE_UPDATE_SHARE, StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_USE, name + "_" + share);
    }

    public static final class OfflineStatistics implements ScheduleJobService.Job {
        private long mLastCanRunTimeMillis = 0;

        @Override
        public long getIntervalTime() {
            return TimeConstant.ONE_DAY;
        }

        private static void statisicsCustomOffline(String event, String key, String value) {
//            statisicsCustom(StatisticsConstant.UMENG_CUSTOM_EVENT_PREFIX_OFFLINE, event,
//                    key, value);
        }

        private static void statisicsCustomOffline(String event, boolean open) {
//            statisicsCustom(StatisticsConstant.UMENG_CUSTOM_EVENT_PREFIX_OFFLINE, event,
//                    StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_STATE,
//                    open ? StatisticsConstant.UMENG_CUSTOM_EVENT_VALUE_OPEN
//                            : StatisticsConstant.UMENG_CUSTOM_EVENT_VALUE_CLOSE);
        }

        @Override
        public void doJob() {

            mLastCanRunTimeMillis = System.currentTimeMillis();
        }

        @Override
        public boolean canRun() {
            return System.currentTimeMillis() - mLastCanRunTimeMillis > getIntervalTime();
        }
    }

    public static void statisticsFaceSecret(String... value) {
//        StringBuilder stringBuilder = new StringBuilder();
//        for (int i = 0; i < value.length; i++) {
//            if (i != 0) {
//                stringBuilder.append(StatisticsConstant.STATISTIC_UNDERLINE);
//            }
//            stringBuilder.append(value[i]);
//        }
//        statisticsCustomFunction(STATISTIC_EVENT_FUN_FUTURE, STATISTIC_EVENT_FUN_KEY, stringBuilder.toString());
    }

    public static void statisticsCustomFunction(String event) {
//        com.common.statistics.StatisticsUtils.statisics(StatisticsConstant.UMENG_CUSTOM_EVENT_PREFIX_FUNCTION, event);
    }

    public static void statisticsCustomFunction(String event, String key, String value) {
//        String isBuy = AppVipManager.isVip() ? STATISTIC_EVENT_VALUE_BUY : STATISTIC_EVENT_VALUE_UNBUY;
//        String comment = statisticsComment();
//        StringBuilder sb = new StringBuilder();
//        sb.append(isBuy).append(StatisticsConstant.STATISTIC_UNDERLINE)
//                .append(comment).append(StatisticsConstant.STATISTIC_UNDERLINE)
//                .append(value);
//        statisticsCustom(StatisticsConstant.UMENG_CUSTOM_EVENT_PREFIX_FUNCTION, event,
//                key, sb.toString());
    }

    public static void statisticsCustom(String prefix, String event, @Nullable String key, @Nullable String value) {
//        String buyuser = BuyUserManager.getInstance().getBuyUserSource();
//        if (TextUtils.isEmpty(key) || TextUtils.isEmpty(value)) {
//            com.common.statistics.StatisticsUtils.statisics(prefix, event,
//                    StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_BUYUSERSOURCE, buyuser,
//                    "usertype", String.valueOf(isBuyUser()));
//        } else {
//            com.common.statistics.StatisticsUtils.statisics(prefix, event,
//                    key, value,
//                    StatisticsConstant.UMENG_CUSTOM_EVENT_KEY_BUYUSERSOURCE, buyuser,
//                    "usertype", String.valueOf(isBuyUser()));
//        }
    }

    public static void statisticAF(List<Purchase> purchases, String page_entrance) {
        if (purchases != null) {
            for (Purchase purchase : purchases) {
                String purchaseToken = purchase.getPurchaseToken();
                String orderId = purchase.getOrderId();
                if (TextUtils.isEmpty(purchaseToken) || TextUtils.isEmpty(orderId)) {
                    break;
                }
                String purchaseSku = purchase.getSku();
                String appsFlyerUID = AppsFlyerLib.getInstance().getAppsFlyerUID(ComponentContext.getContext());
                Map<String, Object> map = new HashMap<>();
                map.put(StatisticsConstant.STATISTIC_EVENT_KEY_AF_UID, appsFlyerUID);
                map.put(StatisticsConstant.STATISTIC_EVENT_KEY_TOKEN, purchaseToken);
                map.put(StatisticsConstant.STATISTIC_EVENT_KEY_SKU, purchaseSku);
                AppsFlyerLib.getInstance().trackEvent(ComponentContext.getContext(), StatisticsConstant.STATISTIC_EVENT_KEY_VIP_NEW, map);
                //String sku, String purchaseToken, String orderId, String sub_entrance
                SubEventUtil.uploadSubscribeEvent(purchaseSku, purchaseToken, orderId, page_entrance);
            }
        }
    }
}
